
var app = getApp();
Page({
    data: {
        motto1: 'Hello ',
        motto2: "World",
        scroll_top: 0,
        scroll_view_height: 200,
    },
    onLoad: function () {},
    scroll_up: function(e) {
        this.setData({
        scroll_top: (this.data.scroll_top-20)>=0 ? this.data.scroll_top-20 : this.data.scroll_top
        });
    },
    scroll_down: function(e) {
        this.setData({
        scroll_top: (this.data.scroll_top+20)<=this.data.scroll_view_height ? this.data.scroll_top+20 : this.data.scroll_top
        });
    },
    scroll_move: function(e) {
        // console.log(e);
        if (null == this.data.last_move) {
        } else {
            var y_offset = e.touches[0].pageY - this.data.last_move.touches[0].pageY;
            this.setData({
                scroll_top: ((this.data.scroll_top+y_offset)<=this.data.scroll_view_height && (this.data.scroll_top+y_offset)>=0) ? this.data.scroll_top+y_offset : this.data.scroll_top
            });
        }
        this.setData({
            last_move: e
        });
    },
});